package day18.Junit_reflect_annotation_proxy;

import org.junit.Test;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

//LocalDateTime的用法
public class Previous
{
    public static void main(String[] args)
    {
        LocalDateTime time=LocalDateTime.now();
        LocalDateTime time2 = time.plusMonths(2);//改时间会返回一个新的LocalDateTime对象。
                                              // 线程很安全不会因为改而影响其他线程。
        System.out.println(time2);
        System.out.println(time);
        System.out.println(time.getYear());
        System.out.println(time.getMonth());
        System.out.println(time.getDayOfMonth());
        //获取星期几
        System.out.println(time.getDayOfWeek());
        System.out.println(time.getDayOfWeek().getValue()+"*******");
        System.out.println(time.getDayOfYear());
        System.out.println(time.getHour());
        System.out.println(time.getMinute());
        System.out.println(time.getSecond());
        System.out.println(time.getNano());

        //格式化LocalDatetime：DateTimeFormatter                                 如果想要周三这种必须后面加EEE，a代表上午还是下午
        DateTimeFormatter dtf=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss EEE a");
        System.out.println(dtf.format(time));//把localdatetime转换成String了

    }
    @Test
    public void test2()
    {
        String str = ",apple,banana,orange,grape";

        // 使用逗号作为分隔符
        String[] fruits = str.split(",");//装了子字符串的数组
//        String[] fruits = str.split("，");//装了子字符串的数组
        System.out.println(fruits.length);//5
        // 打印结果
        for (String fruit : fruits) {
            System.out.println(fruit);
        }


    }


}
